﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace huaguwang
{
    public class D_T_MasterClass_Exp:D_T_MasterClass
    {
        /// <summary>
        /// 分页获取数据量
        /// </summary>
        /// <returns></returns>
        public int GetPageCount(string title)
        {
            string strSQL = ExpandMSSQL.GetPageSQL(
                "T_MasterClass ",
                "flag=1 and MasterName like '%'+@MasterName+'%'");
            SqlParameter parm = new SqlParameter("@MasterName", SqlDbType.NVarChar, 100);
            parm.Value = title;
            var PageCount = MSSQLHelper.SQLConType.C1.Exp_GetSingle(strSQL, parm);
            return PageCount.Exp_IntTryParse();
        }

        /// <summary>
        /// 分页获取数据信息
        /// </summary>
        /// <param name="Begin">起始目录</param>
        /// <param name="Size">每页显示的数量</param>
        /// <returns></returns>
        public List<M_T_MasterClass> GetPageList(int Begin, int Size, string title)
        {
            string strSQL = ExpandMSSQL.GetPageSQL(
            Begin,
            Size,
            "id,Explain,MasterName,ObjectName,TeacDate,TeacPrice",
            "T_MasterClass",
            "id",
            "flag=1 and MasterName like '%'+@MasterName+'%'",
            "AddDate desc");
            SqlParameter parm = new SqlParameter("@MasterName", SqlDbType.NVarChar, 100);
            parm.Value = title;
            var List = MSSQLHelper.SQLConType.C1.Exp_GetList(strSQL,
            DR => new M_T_MasterClass()
            {
                id = DR["id"].Exp_IntTryParse(),
                Explain = DR["Explain"].Exp_Trim().Exp_RegexHTML().Exp_SubStringByLength(52,"......."),
                MasterName = DR["MasterName"].Exp_Trim(),
                ObjectName  =DR["ObjectName"].Exp_Trim(),
                TeacDate = DR["TeacDate"].Exp_DateTimeTryParse().Exp_GetString(ExpandDateTime.DateFormType.CnDate).Exp_DateTimeTryParse(),
                TeacPrice  =DR["TeacPrice"].Exp_DecimalTryParse(),                     
            }, parm);
            return List;
        }
    }
}
